package org.xiaojinlong.exam;

import java.util.Scanner;

/**
 * @author Jin Long
 * 2015/9/19
 */
public class WakeUp {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {
            int p = scanner.nextInt();
            int q = scanner.nextInt();
            int l = scanner.nextInt();
            int r = scanner.nextInt();

            int[][] pArr = new int[p][2];
            int[][] qArr = new int[q][2];

            for (int i = 0; i < p; i++) {
                pArr[i][0] = scanner.nextInt();
                pArr[i][1] = scanner.nextInt();
            }

            for (int i = 0; i < q; i++) {
                qArr[i][0] = scanner.nextInt();
                qArr[i][1] = scanner.nextInt();
            }

            int count = 0;
            outter: for (int i = l; i <= r; i++) {
                for (int j = 0; j < q; j++) {
                    for (int k = qArr[j][0]; k <= qArr[j][1]; k++) {
                        for (int m = 0; m < p; m++) {
                            if ((k + i) >= pArr[m][0] && (k + i) <= pArr[m][1]) {
                                count++;
                                continue outter;
                            }
                        }
                    }
                }
            }
            System.out.println(count);
        }
    }
}
